<template>
	<view>
		<view style="display: flex;width: 90%;margin: 10rpx auto;">
			<uni-easyinput  type="textarea" v-model="neirong" placeholder="快来说点什么吧……" :inputBorder="false" />
		</view>
		<view style="display: flex;width: 90%; margin: 10rpx auto;">
			<uni-file-picker limit="9" title="请选择照片" :del-icon="true" mode="grid" v-model="imageValue" file-mediatype="image" @success="fanhuiurl" @delete="delpic"></uni-file-picker>
		</view>
		<view @click="fabu" style="display: flex;width: 40%;background-color: blue;color: white;border-radius: 20rpx;margin: 90rpx auto 0 auto;justify-content: center;align-items: center;padding: 10rpx 0;">
			发布
		</view>
	</view>
</template>

<script>
	import getDateTime from '@/common/getdateTime.js';
	export default {
		data() {
			return {
				meiyi_userinfo:{},
				imageValue:[],
				neirong:''
			}
		},
		async onLoad() {
			this.meiyi_userinfo=await uniCloud.getCurrentUserInfo()
		},
		methods: {
			fabu(){
				if(this.neirong=='' && this.imageValue==''){
					uni.showToast({
						title: '未填写内容或未添加图片',
						icon: 'none',
						duration: 3000
					})
					return
				}
				uni.showLoading({
					title:"发布中……"
				})
				uniCloud.callFunction({
					name:"pengyouquan",
					data:{
						huiyuanid:this.meiyi_userinfo.uid,
						neirong:this.neirong,
						tupianurl:this.imageValue,
						dianzanshu:15,
						fabudate:getDateTime.dateTimeStr('y-m-d h:i:s')
					}
				}).then(res=>{
					uni.hideLoading()
					uni.navigateTo({
						url: '/pages/banjifengcai/banjifengcai'
					});
				})
			},
			delpic(e){
				// console.log("e",e.tempFile.fileID)
				uniCloud.callFunction({
					name:"delpic",
					data:{
						picurl:e.tempFile.fileID
					}
				}).then(res=>{
				})
			},
			// 上传成功
			fanhuiurl(e){
				console.log("12ee",this.imageValue)
				// this.zhaopian=e.tempFiles[0].fileID
			},
			del(e){
				console.log("abck",e)
			}
		},
	}
</script>

<style>
page{
	/* background-color: #f8f8f8; */
}
</style>
